import React from 'react';
import PropTypes from 'prop-types';
import createClass from 'create-react-class';
import Sectioner from './section';
/*
const Main = ({ title,main }) => {
    return <div id="contain">
        <h1>{title}</h1>
        <article>
            {main.map((m, mi) => <Sectioner key={mi} {...m} />)}
        </article>
    </div>
}
*/
const Main = createClass({
    propTypes:{
        title:PropTypes.string,
        main:(props,propsName) => {
            if(props.main.length <= 2) {
                return new Error('arg length is error')
            } else {
                return null;
            }
        }
    },
    getDefaultProps(){
        return {
            title:'333',
            main:[
                {
                    title: '外观',
                    list: [{
                            "id": "c0001",
                            "name": "秒白",
                            "colorValue": "eeeef0",
                            "basePrice": 0,
                        }
                    ]
                }
            ]
        }
    },
    render(){
        // 获取组件传递的props的值
        const  {title,main} = this.props;
        return <div id="contain">
        <h1>{title}</h1>
        <article>
            {main.map((m, mi) => <Sectioner key={mi} {...m} />)}
        </article>
    </div>
    }
})
export default Main;